package com.cg.controller;
import com.cg.dto.DeleteLikeDTO;
import com.cg.entity.UserLike;
import com.cg.result.R;
import com.cg.service.AccountService;
import com.cg.service.ILikeService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author 加
 * @since 2025-01-17
 */
@RestController
@CrossOrigin
@RequestMapping("/api/like")
@Api(value = "likeController",description = "欢迎来到收藏管理",tags = "收藏管理")
public class LikeController {
    @Autowired
    private ILikeService likeService;
    @Autowired
    private AccountService accountService;

    @GetMapping("showLikes")
    @ApiOperation("展示所有收藏")
    public R<List<UserLike>> showLikes(){
        Long userId=accountService.getCurrentUserId();
        return likeService.showLikes(userId);
    }

    @ApiOperation("取消收藏")
    @DeleteMapping("deleteLike")
    public R deleteLike(DeleteLikeDTO deleteLikeDTO){
        return likeService.deleteLike(deleteLikeDTO);
    }

}
